import time as t
import datetime 

class Time():
    def __init__(self):
        self.time1=0
        self.time2=0
        self.pt=''
        self.ptt=''
        self.list1=[]
        self.list2=['年','月','日','时','分','秒']
        self.list3=[]
        
    def __str__(self):
        return self.pt

    def __repr__(self):
        return self.pt
    
    def start(self):
        self.pt = '请先调用stop()停止计时'
        if self.time1 ==0:
            self.time1 = t.perf_counter()
            print('开始计时')
        else :
            print('请先调用stop()停止计时')
            
    def stop (self):
        if self.time1==0:
            print('请先调用start()开始计时')
        else:
            self.time2=t.perf_counter()
            self._fun()
            print(self.pt)
        
    def _fun(self):
        self.pt = '总共用了：'
        last=self.time2-self.time1
        f1=datetime.datetime(1,1,1,0,0,0,0)
        f2=datetime.timedelta(seconds=last)
        result = f1+f2
        result.timetuple()
        for each in range(6):
            if each <=2:
                self.list1.append(result.timetuple()[each]-1)
                self.pt+= str(self.list1[each]) + self.list2[each]
            else :
                self.list1.append(result.timetuple()[each])
                self.pt+= str(self.list1[each])+ self.list2[each]
                          
        self.time1=0
        self.time2=0

        
    def __add__(self,other):
        self.ptt='总共用时:'
        for each_1 in range(6):
            self.list3.append(self.list1[each_1]+other.list1[each_1])
            if self.list3[each_1]:
                self.ptt+=str(self.list3[each_1])+self.list2[each_1]
                
        return self.ptt
        
    
